package com.boot;

import com.boot.bean.Person;
import com.boot.config.AuthorSettings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@SpringBootApplication
public class BootPractiseApplication {
	@Autowired
	private AuthorSettings authorSettings;

	@RequestMapping(value = "/")
	public String index() {
		return "book name is:"+authorSettings.getName()+" and author age is:" + authorSettings.getAge();
	}

	@PostMapping(value = "/valid", produces = "application/json;charset=utf-8")
	public Object testValid(@Validated @RequestBody Person person) {
		System.out.println(person);
		return null;
	}

	public static void main(String[] args) {
		SpringApplication.run(BootPractiseApplication.class, args);
	}
}
